#ifndef WINDOW_HPP
#define WINDOW_HPP 1

#include "exception.hpp"
#include "debug.hpp"
#include <cstdint>
#include <fstream>

namespace fur
{
   const int WINDOW_SIZE = 0x1000000;
   const int WINDOW_SIZE_MASK = WINDOW_SIZE - 1;
   class Window
   {
   public:
      Window(size_t buffsize = WINDOW_SIZE) throw(Exception);//buffsize must be not less than 0x400000(the default window size for RAR)
      ~Window() throw();
      inline void add_byte(uint8_t byte) throw();
      void copy_string(size_t distance, size_t size) throw();
      size_t get_position() const throw()
      { return position; };
      size_t get_maxsize() const throw()
      { return maxsize; };
      uint8_t *get_data() throw()
      { return data; };
   private:
      uint8_t *data;
      size_t position;
      size_t maxsize;
   };
   void Window::add_byte(uint8_t byte) throw()
   {
      data[position] = byte;
      ++position;
      position %= maxsize;
   }
} // end of namespace fur
#endif /* window.hpp */
